package com.situ.cookie;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/cookie1")
public class Cookie1 extends HttpServlet{

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("Cookie1.service()");
		
		Cookie cookie1 = new Cookie("goods", "IPhone");
		cookie1.setMaxAge(10*60); //单位是秒
		Cookie cookie2 = new Cookie("name", "sgx");
		cookie2.setMaxAge(24 * 60 * 60); //24小时 x 60分钟 x 60秒

		resp.addCookie(cookie1);
		resp.addCookie(cookie2);
		
	}//service
}
